package com.xbts.system.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xbts.system.mapper.SysFileDownloadLogMapper;
import com.xbts.system.domain.CnFileDownloadLog;
import com.xbts.system.service.ISysFileDownloadLogService;
import com.xbts.common.utils.DateUtils;
import com.xbts.common.utils.SecurityUtils;

/**
 * 文件下载日志Service业务层处理
 * 
 * @author xbts
 * @date 2023-09-05
 */
@Service
public class SysFileDownloadLogServiceImpl  extends ServiceImpl<SysFileDownloadLogMapper, CnFileDownloadLog> implements ISysFileDownloadLogService {

    /**
     * 查询文件下载日志列表
     *
     * @param cnFileDownloadLog 文件下载日志
     * @return 文件下载日志
     */
    @Override
    public List<CnFileDownloadLog> selectSysFileDownloadLogList(CnFileDownloadLog cnFileDownloadLog) {
        QueryWrapper<CnFileDownloadLog> queryWrapper = cnFileDownloadLog.queryWrapper();
        queryWrapper.eq("create_by", SecurityUtils.getUserId());
        return list(queryWrapper);
    }

    /**
     * 查询文件下载日志
     *
     * @param id 文件下载日志主键
     * @return 文件下载日志
     */
    @Override
    public CnFileDownloadLog selectSysFileDownloadLogById(String id) {
        return getById(id);
    }

    /**
     * 新增文件下载日志
     *
     * @param cnFileDownloadLog 文件下载日志
     * @return 结果
     */
    @Override
    public boolean insertSysFileDownloadLog(CnFileDownloadLog cnFileDownloadLog) {
        cnFileDownloadLog.setCreateBy(SecurityUtils.getUserId().toString());
        return save(cnFileDownloadLog);
    }

    /**
     * 修改文件下载日志
     *
     * @param cnFileDownloadLog 文件下载日志
     * @return 结果
     */
    @Override
    public boolean updateSysFileDownloadLog(CnFileDownloadLog cnFileDownloadLog) {
        cnFileDownloadLog.setUpdateBy(SecurityUtils.getUserId().toString());
        cnFileDownloadLog.setUpdateTime(DateUtils.getNowDate());
        return updateById(cnFileDownloadLog);
    }

    /**
     * 批量删除文件下载日志
     *
     * @param ids 需要删除的文件下载日志主键
     * @return 结果
     */
    @Override
    public boolean deleteSysFileDownloadLogByIds(List<String> ids) {
        return removeBatchByIds(ids);
    }

    /**
     * 删除文件下载日志信息
     *
     * @param id 文件下载日志主键
     * @return 结果
     */
    @Transactional
    @Override
    public boolean deleteSysFileDownloadLogById(String id) {
      return removeById(id);
    }

}
